window.addEvent('domready', function() {
	
	// TOOLTIPS
	$$('a.tooltip').each(function(element,index) {
		var content = element.get('title').split('::');
		element.store('tip:title', content[0]);
		element.store('tip:text', content[1]);
	});
	//create the tooltips
	var tipz = new Tips('.tooltip',{
			className: 'tooltipTop',
			fixed: true,
			hideDelay: 50,
			showDelay: 50
		});
		tipz.addEvents({
			'show': function(tip) {
				tip.fade('in');
				
			},
			'hide': function(tip) {
				tip.fade('out');
			}
		});
	
	// TOP BLOCK DROPPING DOWN
	var topBlock = $('rt-top');
	if(topBlock != null) {
	var slideTop = new Fx.Tween(topBlock, { duration: 800, transition: Fx.Transitions.Expo.easeOut, link: 'cancel', property: 'height'});
	topBlock.addClass('closed');
	
	$$('.modTop li a').each(function(el) {
		el.addEvent('click', function(e){
			var event = new Event(e);
			event.stop();
			if(topBlock.hasClass('closed')) {
				slideTop.start(0, 160);
				topBlock.addClass('opened');
				topBlock.removeClass('closed');
			} else {
				slideTop.start(160, 0);
				topBlock.removeClass('opened')
				topBlock.addClass('closed');
			}
			
			
			if($('click_us') != null) {
				$('click_us').setStyle('display','none');
			}
		})
	})
	
	$('closeTop').addEvent('click', function(){
		slideTop.start(160, 0);
		topBlock.removeClass('opened');
		topBlock.addClass('closed');
	});
	}
	
	// FIND OUT BUTTON
	var find_button = $('findoutmoreBtn');
	if(find_button != null) {

		var slideBtn = new Fx.Tween(find_button, { duration: 300, transition: Fx.Transitions.Circ.easeOut, link: 'cancel'});
		find_button.addEvent('mouseover', function(){
			slideBtn.start('top',0);
		});
		find_button.addEvent('mouseout', function(){
			slideBtn.start('top',-56);
		});
		
	}
	
	var sidebarMenuElem = $$('#rt-main ul.menu li a');
	sidebarMenuElem.set('morph', {duration: 200});
	sidebarMenuElem.addEvents({
		mouseenter: function(){this.morph({'background-color': '#f8f8f8', 'color':'#151515'});
    	},
		mouseleave: function(){this.morph({'background-color': '#fff', 'color':'#777'});
    	}
	});
	
	 	
	// homepage hover effects for Projects module
	var modProjectsImg = $$('.modProjects img');
	 modProjectsImg.each(function(el) {
		
		if(el.getParent('a')) {
			var parentImg = el.getParent('a').setStyle('position','relative');
			var spanhover = new Element('span', {'class': 'hovereffect', styles: {opacity: 0}});
			parentImg.adopt(spanhover);
			parentImg.addEvent('mouseover', function(){
				spanhover.tween("opacity", 0.00001, 1);
			})
			parentImg.addEvent('mouseout', function(){
				spanhover.tween("opacity", 1, 0.00001);
			})
		}
	 })
	 
	 if($$('.sigplus-gallery') != null) {
	 	$$('.sigplus-gallery li').each(function(el,i){
			if ((i + 1) % 4 == 0) {
				el.addClass('last-element');
			}
		});
	 }

	 
});